package com.rabbit.eap.framework.config.jackson.deserializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.rabbit.eap.framework.config.util.StringToDoubleUtil;

import java.io.IOException;

/**
 * @projectName eap
 * @packageName com.rabbit.eap.framework.config.jackson.deserializer
 * @className JacksonDoubleDeserializer
 * @author： rabbit
 * @version： 1.0
 * @since： 2020/4/27 20:54
 * <p>Description: JacksonDoubleDeserializer </p>

 */
public class JacksonDoubleDeserializer extends JsonDeserializer<Double> {

    @Override
    public Double deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
        String string = jsonParser.getText();
        return StringToDoubleUtil.convert(string);
    }
}
